Skip to content

fix: missing max num level checks - #596

Merged
proost merged 1 commit into
apache:masterfrom
proost:fix-missig-max-num-level-checks
Nov 23, 2026
Merged

proost merged 1 commit into
apache:masterfrom
proost:fix-missig-max-num-level-checks

Conversation

@proost

@proost proost commented Nov 21, 2026

Copy link
Copy Markdown
Member

follow up: #595

As leerho said, n can't be overflowing. So number of levels can't exceed 64. But current implementation in deserialize method doesn't check this.

@proost
proost requested a review from leerho November 21, 2026 09:12
@proost proost self-assigned this Nov 21, 2026

@leerho leerho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is right. Items at level h weigh 2^h and n is at most 2^63 - 1, so a sketch never has more than 63 levels, and 64 keeps every lg_weight at 63 or less, so the shifts in the weight check from apache/datasketches-cpp#595 · REQ: reject n that isn't the… are always defined. I confirmed the new section fails on master and passes merged with apache/datasketches-cpp#595 · REQ: reject n that isn't the… under ASan and UBSan.

@proost
proost merged commit 5241bfa into apache:master Nov 23, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants